<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="author" content="Guillaume Laborde - Guillaume Lameyre" />
<link rel="stylesheet" media="screen" type="text/css" title="style" href="css/style.css" />
<title>ContactBook</title>
</head>

<body>

	<c:set var="account" value="${sessionScope.account}" />
	<c:set var="contacts" value="${requestScope.contacts}" />
	<c:set var="group" value="${requestScope.group}" />
	
	<c:if test="${empty account}">
		<c:redirect url="Index" />
	</c:if>
	
	<c:if test="${empty group}">
		<c:redirect url="Group" />
	</c:if>
		
	<div id="mainframe">
		<c:import url="include/privateBanner.html" />
		<h1>Information sur le groupe</h1>
		<div id="content">
		
			<jsp:useBean id="group" class="contactbook.model.Group" scope="page" />
			
			<fieldset>
				<legend><img src="images/group.png" alt="" /> <jsp:getProperty name="group" property="name" /></legend>
				<div class="right">
					<form action="UpdateGroup" method="POST" class="inline">
						<input type="image" src="images/group_edit.png" alt="Modifier" title="Modifier" />
						<input type="hidden" name="groupId" value="<jsp:getProperty name="group" property="id" />" />
					</form>
					<form action="DeleteGroup" method="POST" class="inline">
			            <input type="image" src="images/group_delete.png" alt="Supprimer" title="Supprimer" />
                       	<input type="hidden" name="groupId" value="<jsp:getProperty name="group" property="id" />" />
					</form>
				</div>
				
				<p>
					<c:set var="description" value="${group.description}" />
					<c:if test="${not empty description}">
						Description : <jsp:getProperty name="group" property="description" />
					</c:if>
				</p>
				
				<p>
					<c:if test="${empty contacts}">
						<span class="warning">Ce groupe ne recense aucun contact</span>
					</c:if>
					<c:if test="${not empty contacts}">
						Ce groupe recense <c:out value="${fn:length(contacts)}" /> contact<c:if test="${fn:length(contacts) != 1}">s</c:if>.
						<fieldset>
		            		<legend>Liste des contacts</legend>
			            	<table class="border">
								<c:forEach var="contact" items="${contacts}">
									<jsp:useBean id="contact" class="contactbook.model.Contact" scope="page" />
									<tr>
										<td width="20px"><img src="images/contact.png" alt="" /></td>
			          					<td><jsp:getProperty name="contact" property="firstName" /> <jsp:getProperty name="contact" property="lastName" /></td>
									</tr>
								</c:forEach>
							</table>
						</fieldset>
					</c:if>
				</p>
			
				<form action="Group" method="POST">
					<table>
						<tr><td class="button"><input type="image" src="images/back.png" alt="Retour" /></td></tr>
					</table>
				</form>
			</fieldset>
		
		</div>
		<c:import url="include/bottom.html" />
	</div>

</body>
</html>